<template>
  <!-- 设置 -->
  <avue-form ref="form" v-model="form" :option="option" @submit="handleSubmit"></avue-form>
</template>

<script>
import { setting } from '@/api/supplier/info'
const dic = [
  { label: '是', value: '0' },
  { label: '否', value: '1' }
]
export default {
  name: 'supplierInfoSetting',
  props: ['id', 'info'],
  data() {
    return {
      form: this.info || {},
      option: {
        submitText: '确定',
        emptyText: '取消',
        emptyBtn: false,
        submitBtn: false,
        column: [
          {
            label: '是否协同',
            labelWidth: 120,
            type: 'select',
            dicData: dic,
            props: { label: 'label', value: 'value' },
            span: 23,
            prop: 'isSynergy',
            rules: [
              {
                required: true,
                message: '请输入是否协同',
                trigger: 'change'
              }
            ]
          },
          {
            label: '是否参与考核',
            labelWidth: 120,
            type: 'select',
            dicData: dic,
            props: { label: 'label', value: 'value' },
            span: 23,
            prop: 'isCheck',
            rules: [
              {
                required: true,
                message: '请输入是否参与考核',
                trigger: 'change'
              }
            ]
          },
          {
            label: '采购工程师',
            labelWidth: 120,
            span: 23,
            prop: 'purchaseEngineer',
            rules: [
              {
                required: true,
                message: '请输入采购工程师',
                trigger: 'blur'
              }
            ]
          }
        ]
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          let data = { ...this.form, id: this.id }
          setting(data).then(
            () => {
              this.$message.success('设置成功!')
              // console.log(res)
              this.$emit('update:visible', false)
              this.$emit('refresh')
            },
            error => {
              window.console.log(error)
            }
          )
        }
      })
    }
  }
}
</script>

<style></style>
